<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">
	<p:outputPanel id="painelPesquisa" rendered="#{logradouroBean.modoPesquisa}">
		<p:panel header="#{msg['titulo.logradouro.pesquisa']}" id="painelPesquisaLogradouro">
			<p:focus for="ufPesquisa" id="focusPaginaPesquisa"/>
			<h:panelGrid columns="2" id="painel2ColunasPesquisa">
				<h:outputLabel value="#{msg['label.logradouro.uf']}" for="ufPesquisa" id="labelUfPesquisa" />
				<p:selectOneMenu value="#{logradouroBean.entity.bairro.municipio.uf}" id="ufPesquisa" title="#{msg['title.logradouro.uf']}" valueChangeListener="#{logradouroBean.obterListaMunicipios}" effect="fade" immediate="true">
					<f:selectItem itemLabel="--Selecione--" />
					<f:selectItems value="#{utilBean.listaUFs}" />
					<p:ajax event="change" update="municipioPesquisa,bairroPesquisa" immediate="true"/>
				</p:selectOneMenu>
				<h:outputLabel value="#{msg['label.logradouro.municipio']}" for="municipioPesquisa" id="labelMunicipioPesquisa" />
				<p:selectOneMenu value="#{logradouroBean.entity.bairro.municipio}" id="municipioPesquisa" title="#{msg['title.logradouro.municipio']}" converter="municipioConverter" converterMessage="Erro ao converter Municipio" valueChangeListener="#{logradouroBean.obterListaBairros}" effect="fade" immediate="true">
					<f:selectItem itemLabel="--Selecione--" itemValue="" />
					<f:selectItems value="#{logradouroBean.listaMunicipios}" var="municipio" itemLabel="#{municipio.nome}" itemValue="#{municipio}" />
					<p:ajax event="change" update="bairroPesquisa" immediate="true"/>
				</p:selectOneMenu>
				<h:outputLabel value="#{msg['label.logradouro.bairro']}" for="bairroPesquisa" id="labelBairroPesquisa" />
				<p:selectOneMenu value="#{logradouroBean.entity.bairro}" id="bairroPesquisa" title="#{msg['title.logradouro.bairro']}" converter="bairroConverter" converterMessage="Erro ao converter bairro">
					<f:selectItem itemLabel="--Selecione--" itemValue="" />
					<f:selectItems value="#{logradouroBean.listaBairros}" var="bairro" itemLabel="#{bairro.nome}" itemValue="#{bairro}" />
				</p:selectOneMenu>
				<h:outputLabel value="#{msg['label.logradouro.nome']}" for="nomePesquisa" id="labelNomePesquisa" />
				<p:inputText value="#{logradouroBean.entity.nome}" id="nomePesquisa" size="60" maxlength="255" title="#{msg['title.logradouro.nome']}"/>
			</h:panelGrid>
		</p:panel>
	</p:outputPanel>
	<p:outputPanel id="painelDetalhePesquisa" rendered="#{logradouroBean.modoDetalhePesquisa}" >
		<p:dataTable value="#{logradouroBean.listaEntities}" var="logradouro" id="dataTableDetalhePesquisa">
			<p:column id="colunaNomeLogradouro" sortBy="#{logradouro.nome}">
				<f:facet name="header"><h:outputText value="#{msg['label.logradouro.nome']}" id="labelColunaNome"/></f:facet>
				<h:outputText value="#{logradouro.nome}" id="nomeDetalhe"/>
			</p:column>
			<p:column id="colunaCepLogradouro" sortBy="#{logradouro.cep}">
				<f:facet name="header"><h:outputText value="#{msg['label.logradouro.cep']}" id="labelColunaCep"/></f:facet>
				<h:outputText value="#{logradouro.cep}" id="cepDetalhe" converter="cepConverter"/>
			</p:column>
			<p:column id="colunaBairroLogradouro" sortBy="#{logradouro.bairro.nome}">
				<f:facet name="header"><h:outputText value="#{msg['label.logradouro.bairro']}" id="labelColunaBairro"/></f:facet>
				<h:outputText value="#{logradouro.bairro.nome}" id="bairroDetalhe"/>
			</p:column>
			<p:column style="text-align:center" id="colunaBotaoEditar">
				<f:facet name="header"><h:outputText value="Editar" id="labelColunaEditar"/></f:facet>
				<p:commandLink update="@form" actionListener="#{logradouroBean.editar}" id="botaoEditarLogradouro" ajax="true" immediate="true">
					<h:graphicImage library="imagens" name="small_edit.png" id="imagemEditarLogradouro"/>
                	<f:setPropertyActionListener value="#{logradouro}" target="#{logradouroBean.entity}"/>  
            	</p:commandLink>
			</p:column>            	  
			<p:column style="text-align:center" id="colunaVisualizar">
				<f:facet name="header"><h:outputText value="Visualizar" id="labelColunaVisualizar"/></f:facet>
				<p:commandLink update="@form" actionListener="#{logradouroBean.visualizar}" id="botaoVisualizarLogradouro" ajax="true" immediate="true">
					<h:graphicImage library="imagens" name="small_find.png" id="imagemVisualizarLogradouro"/>
                	<f:setPropertyActionListener value="#{logradouro}" target="#{logradouroBean.entity}" />
				</p:commandLink>
			</p:column>
			<p:column style="text-align:center" id="colunaExcluir">
				<f:facet name="header"><h:outputText value="Excluir" id="labelExcluir"/></f:facet>
				<p:commandLink update="@form" actionListener="#{logradouroBean.iniciarExclusao}" id="botaoExcluirLogradouro" ajax="true" immediate="true">
					<h:graphicImage library="imagens" name="small_delete.png" id="imagemExcluirLogradouro"/>
                	<f:setPropertyActionListener value="#{logradouro}" target="#{logradouroBean.entity}" />
            	</p:commandLink>                        
			</p:column>
		</p:dataTable>
	</p:outputPanel>
</ui:composition>